package rexsee.core.receiver;

import rexsee.core.alarm.RexseeAlarm;
import rexsee.core.utilities.Utilities;
import rexsee.service._Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class _Receiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		try {
			String action = intent.getAction();
			if (action == null) {
				Utilities.open(context, intent.getDataString());
			} else if (action.startsWith(RexseeAlarm.ALARM_ACTION)) {
				RexseeAlarm.exec(context, intent.getStringExtra(RexseeAlarm.ALARM_EXTRA_ARGU));
			} else if (action.equals("android.intent.action.BOOT_COMPLETED")) {
				RexseeAlarm.updateAlarm(context);
				try {
					context.startService(new Intent(context, _Service.class));
				} catch (Exception e) {
				}
			} else {
				Utilities.open(context, intent.getDataString());
			}
		} catch (Exception e) {
		}
	}

}
